package com.wgh.product.api.client;

import com.wgh.common.vo.Result;
import com.wgh.common.vo.PageResult;
import com.wgh.product.dto.ProductReviewDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * 商品评价服务客户端
 * 用于其他服务调用商品评价服务的API
 */
@FeignClient(name = "shop-product-service", path = "/api/product-review")
public interface ProductReviewClient {

    /**
     * 分页查询商品评价
     */
    @GetMapping("/page")
    Result<PageResult<ProductReviewDTO>> getReviewPage(
            @RequestParam(required = false) Map<String, Object> params,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize);

    /**
     * 根据商品ID查询评价列表
     */
    @GetMapping("/product/{productId}")
    Result<PageResult<ProductReviewDTO>> getReviewsByProductId(
            @PathVariable Long productId,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize);

    /**
     * 根据用户ID查询评价列表
     */
    @GetMapping("/user/{userId}")
    Result<PageResult<ProductReviewDTO>> getReviewsByUserId(
            @PathVariable Long userId,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize);

    /**
     * 根据评价ID获取评价详情
     */
    @GetMapping("/{id}")
    Result<ProductReviewDTO> getReviewDetail(@PathVariable Long id);

    /**
     * 新增商品评价
     */
    @PostMapping
    Result<Boolean> addReview(@RequestBody ProductReviewDTO productReviewDTO);

    /**
     * 更新评价状态
     */
    @PutMapping("/{id}/status")
    Result<Boolean> updateReviewStatus(@PathVariable Long id, @RequestParam Integer status);

    /**
     * 批量更新评价状态
     */
    @PutMapping("/status/batch")
    Result<Boolean> batchUpdateReviewStatus(@RequestParam List<Long> ids, @RequestParam Integer status);

    /**
     * 回复评价
     */
    @PutMapping("/{id}/reply")
    Result<Boolean> replyReview(@PathVariable Long id, @RequestParam String replyContent);

    /**
     * 根据商品ID统计评价信息
     */
    @GetMapping("/statistics/product/{productId}")
    Result<Map<String, Object>> getReviewStatisticsByProductId(@PathVariable Long productId);

    /**
     * 获取有图评价列表
     */
    @GetMapping("/image/product/{productId}")
    Result<PageResult<ProductReviewDTO>> getImageReviewsByProductId(
            @PathVariable Long productId,
            @RequestParam(defaultValue = "1") Integer pageNum,
            @RequestParam(defaultValue = "10") Integer pageSize);

    /**
     * 获取商品的平均评分
     */
    @GetMapping("/average-score/product/{productId}")
    Result<Double> getAverageScoreByProductId(@PathVariable Long productId);

    /**
     * 批量查询评价
     */
    @GetMapping("/batch")
    Result<List<ProductReviewDTO>> getReviewsByIds(@RequestParam List<Long> ids);
}